import Vuex from 'vuex'
import { getCart } from '../api/cart'

export default Vuex.createStore({
  state: {
    cartCount: 0
  },
  getters: {
  },
  mutations: {
    addCart(state, payload) {
      state.cartCount = payload.count
    }
  },
  actions: {
    async updateCart(ctx) {
      const { data } = await getCart()
      ctx.commit('addCart', {
        count: data.length || 0
      })
      console.log(data,'getCart')
    }
  },
  modules: {}
});
